/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package vistas;

import entidades.TipoUsuario;
import java.util.List;
import javax.swing.JLabel;
import javax.swing.JProgressBar;
import javax.swing.SwingWorker;
import rn.UsuarioRN;

/**
 *
 * @author g
 */
public class Worker extends SwingWorker<Double, Integer> {

    private final JLabel etiqueta;
    private final JProgressBar progreso;

    public Worker(JLabel unaEtiqueta, JProgressBar unaBarraProgreso) {
        etiqueta = unaEtiqueta;
        progreso = unaBarraProgreso;
    }

    @Override
    protected Double doInBackground() throws Exception {
        publish(0);
        UsuarioRN.getTodosTiposUsuario();
        publish(100);
        return 100.0;
    }

    @Override
    protected void done() {
        new LogIn();
    }

    @Override
    protected void process(List<Integer> chunks) {
        System.out.println("process() esta en el hilo "
                + Thread.currentThread().getName());
        progreso.setValue(chunks.get(0));
    }

}
